<?php
namespace app\frontend\controller;
use think\Db;
use think\Controller;
class Information extends Basic
{
    public function index()
    {
      if(!session('user_name'))
        {
            $user_name='登录';
            $user_register='注册';
            $user_logout='';
        }
        else
        {
        $user_name=session('user_name');
        $user_register='欢迎你';
        $user_logout='退出';
        }

        $this->assign('user_name',$user_name);
        $this->assign('user_register',$user_register);
        $this->assign('user_logout',$user_logout);
        $user_id=session('user_id');

        $ret=db('user')->where("user_id='{$user_id}'")->select();
        $this->assign('ret',$ret);
    	return view('./person/information');
    }
    public function insert()
    { 
         
    	    $user_id=session('user_id');
    	    $user_name=input('user-name2');
    	    $user_idcard=input('user-idcard');
    	    $user_sex=input('radio10');
    	    $user_birth=input('user-birth');
    	    $user_phone = input('post.user-phone');
          $user_email = input('post.uer-email');
               	
        $data=[        
                'user_name'=>$user_name,
                'user_idcard'=>$user_idcard,
                'user_sex'=>$user_sex,
                'user_birthday'=>$user_birth,
                'user_phone'=>$user_phone,
                'user_email'=>$user_email      
         ];

          $ret=db('user')->where("user_id={$user_id}")->update($data);
          if ( $ret == false ) {
                $this->error('修改失败');
            } 
            
            $this->success("修改成功！",Url('/frontend/person/index'));

    }
 }
